home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / examples / programs / palette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  21.5 KB  |  683 lines

  1. #ifndef lint
  2. static char SccsId[]= "@(#)palette.c    V1.12    3/13/95";
  3. #endif
  4. /*
  5. |    file -- palette.c
  6. |====================================================================
  7. |
  8. |     This program shows how to use DV-Tools to manipulate and
  9. |     create a customized color table. When run in a X windows
  10. |     environment, the device used should NOT specify the ':d' option
  11. |     and any X configuration file (such as .Xdefaults) should
  12. |     have the entry DataViews*useDefaultColormap set to NO. Examples
  13. |     of valid device strings include "x", "x:nd" and "x:256".
  14. |
  15. |     The program displays a view of a color palette along with three
  16. |     sliders. Each slider corresponds to one of the three additive
  17. |     primaries, red, green, and blue.
  18. |
  19. |     The color palette represents the current available colors in
  20. |     the color table.  The user is allowed to change the color
  21. |     represented at a particular color index to a new color and
  22. |     thereby create a new color table to be used by applications.
  23. |
  24. |     The user can save the color table entries in a file by selecting
  25. |     the save button.  A filename will be prompted for to save the
  26. |     color table information to.
  27. |
  28. |     Select the QUIT button or type q to exit the program.
  29. |
  30. |=====================================================================
  31. */
  32. #include <windows.h>
  33. /*
  34.  *  DV-Tools header files
  35.  */
  36. #include "std.h"           /* <stdio.h> etc., scalar & macro definitions */
  37. #include "dvstd.h"         /* public types & constants */
  38. #include "dvtools.h"       /* constants used by T routines */
  39. #include "dvGR.h"          /* constants used by window mgt & GR routines */
  40. #include "VOstd.h"         /* constants used by VO & VOob routines */
  41. #include "Tfundecl.h"      /* T routines (screens, drawports & views) */
  42. #include "VOfundecl.h"     /* VO routines (objects) */
  43. #include "VUerfundecl.h"   /* VUer routines (event handling routines) */
  44. #include "VGfundecl.h"     /* VG routines (get info from dgp & vdp) */
  45. #include "GRfundecl.h"     /* GR routines (interface to display device) */
  46.  
  47. /* Constants */
  48. #define  DVPATH            (char *)NULL
  49. #define  DISPFORMS_STB     (char *)NULL
  50. #define  DVDEVICE          (char *)NULL
  51. #define  DVCOLORTABLE      (char *)NULL
  52. #define  VIEW_NAME         "palette.v"
  53. #define  SCREEN_VIEWPORT   (RECTANGLE *)NULL
  54. #define  DRAWING_VIEWPORT  (RECTANGLE *)NULL
  55. #define  BRIGHT           1
  56. #define  DIM           2
  57. #define  PRINT           3
  58. #define  QUIT           4
  59.  
  60. /* Define global variables */
  61. DRAWPORT drawport;      /* how & where to display picture, picture frame */
  62. OBJECT   color_palette,    /* color palette input object */
  63.          menu_bar,         /* menu input object */
  64.          msg_object,       /* vector text message object */
  65.          slider_r,         /* slider for red value */
  66.          slider_g,         /* slider for green value */
  67.          slider_b,         /* slider for blue value */
  68.          color_block,      /* rectangle representing color block */
  69.          text_input;       /* text entry input object */
  70. int      Color_Index,      /* buffer for palette representing color index */
  71.          Menu_Item,        /* buffer for menu input object */
  72.          Red_Value,        /* buffer for red slider */
  73.          Green_Value,      /* buffer for green slider */
  74.          Blue_Value,       /* buffer for blue slider */
  75.          Quit = NO;        /* flag to quit program */
  76. char        filename[40] = {0};   /* filename to store color table */
  77. COLOR_TABLE *color_table;         /* color table */
  78.  
  79. /* Functions defined in palette.c */
  80. int Palette_Pick V_P_((OBJECT client, EVENT_REQUEST er,
  81.               int label, OBJECT loc, ADDRESS args));
  82. int Handle_RGB_Sliders V_P_((OBJECT client, EVENT_REQUEST er,
  83.                 int label, OBJECT loc, ADDRESS args));
  84. int Menu_Pick V_P_((OBJECT client, EVENT_REQUEST er,
  85.            int label, OBJECT loc, ADDRESS args));
  86.  
  87. void Bright V_P_((void));
  88. void Dim V_P_((void));
  89. void Set_colorblock V_P_((void));
  90. int SaveColorFile V_P_((OBJECT client, EVENT_REQUEST er, int label,
  91.             OBJECT loc, ADDRESS args));
  92. ADDRESS RebindVdps V_P_((OBJECT data_obj, ADDRESS vdp, ADDRESS argblock));
  93.  
  94. /*
  95.  *   MAIN PROGRAM
  96.  */
  97. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  98.                      LPSTR lpCmdLine,  int nCmdShow  )
  99. {
  100.   int argc = 0;
  101.   char **argv;
  102.   /*
  103.    *  program arguments
  104.    *    argv[1] - display device name (default is to use DVDEVICE)
  105.    */
  106.  
  107.   /* Define & initialize device name and view filename */
  108.   char *device_name = DVDEVICE; /* default device name */
  109.   char *view_name = VIEW_NAME;  /* default view name */
  110.  
  111.   /* Define display variables */
  112.   OBJECT screen;             /* display device, the window */
  113.   VIEW   view;               /* picture representation of the view file */
  114.  
  115.   /* Control loop variables */
  116.   OBJECT location;           /* the event representation */
  117.   int    event_status;       /* the status of event requests */
  118.  
  119.   /* Other variables */
  120.   OBJECT drawing;            /* graphical representation of screen */
  121.  
  122.   /*--------------------
  123.    *   Initialization
  124.    *
  125.    *   TInit:  perform the initialization of DV-Tools
  126.    *           TInit reads your configuration file and any
  127.    *           environment variables or logical names set.
  128.    */
  129.   make_argv(&argc,&argv,GetCommandLine());
  130.   TInit( DVPATH, DISPFORMS_STB );
  131.  
  132.   /*
  133.    *   TscOpenSet: open a device as a screen object using
  134.    *               specified attributes
  135.    *   TscErase:   erase the entire screen in the default
  136.    *               background color
  137.    *
  138.    *   Set exposure block to YES to insure the window
  139.    *   is ready for drawing when TdpDraw is called.
  140.    */
  141.   if (argc > 1)
  142.     device_name = argv[1];
  143.   screen = TscOpenSet (device_name, DVCOLORTABLE,
  144.                        V_X_EXPOSURE_BLOCK, YES,
  145.                        V_ACTIVE_CURSOR, V_END_OF_LIST);
  146.   if (!screen)
  147.     {
  148.       printf ("Must specify device on command line or");
  149.       printf (" in DataViews configuration file.\n");
  150.       S_EXIT (EXIT_ERR);
  151.     }
  152.   TscErase (screen);
  153.  
  154.   /*
  155.    *   VOscWinEventMask:  sets the screen's window event mask
  156.    */
  157.   VOscWinEventMask ((ULONG) V_KEYPRESS | V_BUTTONPRESS | V_EXPOSE | V_RESIZE,
  158.             (ULONG) 0);
  159.  
  160.   /*
  161.    *   TviLoad:   Load a view in from a file,
  162.    *              default view file palette.v
  163.    *   TdpCreate: Create a DV-Tools window, a drawport.
  164.    *              The drawport is attached to the screen object
  165.    *              specified while view specifies the view to be
  166.    *              displayed on the screen.
  167.    */
  168.   view = TviLoad (view_name);
  169.   if (!view)
  170.     {
  171.       printf ("Could not load view from file ");
  172.       printf ("%s.\n", view_name);
  173.       S_EXIT (EXIT_ERR);
  174.     }
  175.   drawport = TdpCreate (screen, view, SCREEN_VIEWPORT, DRAWING_VIEWPORT);
  176.  
  177.   /*
  178.    *  TviGetDrawing:  Gets a view's drawing object
  179.    *  TobForEachVdp:  Traverses all variable descriptors
  180.    *                  in an object
  181.    *
  182.    *  Traverse all variable descriptors in the drawing object
  183.    *  call the function RebindVdps for each variable descriptor.
  184.    */
  185.   drawing = TviGetDrawing (view);
  186.   TobForEachVdp (drawing, RebindVdps, (ADDRESS) NULL);
  187.  
  188.   /*
  189.    *   TdrGetNamedObject: Gets a named object from a
  190.    *                      drawing.
  191.    *
  192.    *   Get the color palette input object, each slider representing
  193.    *   red, green and blue values, the menu input object, and the
  194.    *   color block from the view's drawing.
  195.    */
  196.   color_palette = TdrGetNamedObject (drawing, "color_palette");
  197.   slider_r = TdrGetNamedObject (drawing, "red_slider");
  198.   slider_g = TdrGetNamedObject (drawing, "green_slider");
  199.   slider_b = TdrGetNamedObject (drawing, "blue_slider");
  200.   menu_bar = TdrGetNamedObject (drawing, "menu");
  201.   color_block = TdrGetNamedObject (drawing, "color_block");
  202.  
  203.   /*
  204.    *   VOvtReference:  Increments reference cnt of vector text obj
  205.    *   VOinReference:  Increments reference cnt of input obj
  206.    *   VOdrObDelete:   Deletes an object from a drawing.
  207.    *
  208.    *   Obtain the message string object and the text entry input
  209.    *   object. Remove these objects from the drawing. These objects
  210.    *   will be drawn when needed.
  211.    */
  212.   msg_object = VOvtReference (TdrGetNamedObject (drawing, "message"));
  213.   VOdrObDelete (drawing, msg_object);
  214.   text_input = VOinReference (TdrGetNamedObject (drawing, "input_text"));
  215.   VOdrObDelete (drawing, text_input);
  216.  
  217.   /*
  218.    *   VUerServiceResultPost:  Post a service result request
  219.    *                           with the event handler.
  220.    *
  221.    *   Post a service result request which monitors the
  222.    *   input objects. The request specifies the
  223.    *   type of the service result flag to be generated.
  224.    */
  225.   VUerServiceResultPost ((OBJECT) 1, Palette_Pick,
  226.                          (ADDRESS) NULL, 0, color_palette, (int)INPUT_DONE, (int)0);
  227.  
  228.   VUerServiceResultPost ((OBJECT) 1, Handle_RGB_Sliders,
  229.                          (ADDRESS) NULL, 0, slider_r,
  230.                          (int)INPUT_DONE | INPUT_ACCEPT, (int)0);
  231.  
  232.   VUerServiceResultPost ((OBJECT) 2, Handle_RGB_Sliders,
  233.                          (ADDRESS) NULL, 0, slider_g,
  234.              (int)INPUT_DONE | INPUT_ACCEPT, (int)0);
  235.  
  236.   VUerServiceResultPost ((OBJECT) 3, Handle_RGB_Sliders,
  237.                          (ADDRESS) NULL, 0, slider_b,
  238.              (int)INPUT_DONE | INPUT_ACCEPT, (int)0);
  239.  
  240.   VUerServiceResultPost ((OBJECT) 1, Menu_Pick,
  241.                          (ADDRESS) NULL, 0, menu_bar, (int)INPUT_DONE, (int)0);
  242.  
  243.   VUerServiceResultPost ((OBJECT) 1, (VUERFCNFUNPTR)SaveColorFile,
  244.                          (ADDRESS) NULL, 0, text_input, (int)INPUT_DONE, (int)0);
  245.  
  246.   /*
  247.    *   TdpDraw:  Draw the contents of the drawport
  248.    */
  249.   TdpDraw (drawport);
  250.  
  251.   /*
  252.    *  GRg_color_table:  Get the color table
  253.    */
  254.   GRg_color_table (&color_table);
  255.  
  256.   /*--------------------
  257.    *   Control loop
  258.    *
  259.    *   Poll the event queue for window events. If the key
  260.    *   represents the character 'q' or 'Q' then quit the program.
  261.    *   Events occurring within input objects will be handled
  262.    *   through the event request handler VUerHandleLocEvent
  263.    *   and continually update the dynamic objects.
  264.    */
  265.   FOREVER
  266.   {
  267.     /*
  268.      *  VOloWinEventPoll:  Poll for the next window event.
  269.      *                     The polling mode used is V_WAIT.
  270.      *                     Therefore, VOloWinEventPoll does not
  271.      *                     return until a masked event is
  272.      *                     generated.  V_WAIT always produces
  273.      *                     a valid location object.
  274.      */
  275.     location = VOloWinEventPoll (V_WAIT);
  276.  
  277.     /*
  278.      *  TdpEraseObject:  Erases an object in the drawport
  279.      *  VOvtSetString:   Sets new vector text obj string value
  280.      *  TdpDrawObject:   Draws an object in the drawport
  281.      *
  282.      *  Erase the current displayed string and clear the vector
  283.      *  text string value.
  284.      */
  285.     TdpEraseObject (drawport, msg_object);
  286.     VOvtSetString (msg_object, "");
  287.     TdpDrawObject (drawport, msg_object);
  288.  
  289.     /*
  290.      *  VUerHandleLocEvent: Service the event. This routine will check
  291.      *                      if the event is used by any input objects
  292.      *                      that may be in the view.
  293.      */
  294.     event_status = VUerHandleLocEvent (location);
  295.     if (event_status == INPUT_UNUSED)
  296.       {
  297.         /*
  298.          *  VOloType:  returns the type of event.  These types
  299.          *             match event types specified in VOscWinEventMask.
  300.          */
  301.         switch (VOloType (location))
  302.           {
  303.           case V_KEYPRESS:
  304.             /*
  305.              *  Check key selected.
  306.              *  VOloKeySym:  Returns the key symbol value of the
  307.              *               location object
  308.              *
  309.              *  If the key symbol represents the characters 'q'
  310.              *  or 'Q' then quit the program.
  311.              */
  312.             switch (VOloKeySym (location))
  313.               {
  314.               case 'q':
  315.               case 'Q':
  316.                 Quit = YES;
  317.                 break;
  318.               default:
  319.                 break;
  320.               }
  321.             break;
  322.  
  323.           case V_EXPOSE:
  324.             /*
  325.              *  VOloRegion:  Returns a rectangle representing the
  326.              *               exposed region on the screen.
  327.              *  TscRedraw:   After erasing, redraws all the drawports
  328.              *               in the screen.
  329.              *  A portion of the window has been exposed and needs
  330.              *  to be redrawn.
  331.              */
  332.             TscRedraw (screen, VOloRegion (location));
  333.             break;
  334.  
  335.           case V_RESIZE:
  336.             /*
  337.              *  TscReset:  Resets all screen drawports after
  338.              *             window resizing
  339.              *  The window size has been changed.
  340.              */
  341.             TscReset (screen);
  342.             break;
  343.  
  344.           default:
  345.             break;
  346.           }
  347.       }
  348.  
  349.     /* exit the program */
  350.     if (Quit == YES)
  351.       break;
  352.  
  353.     /*
  354.      * TdpDrawNext: Update all dynamic objects within a
  355.      *              drawport's view.
  356.      */
  357.     TdpDrawNext (drawport);
  358.   }
  359.  
  360.   /*--------------------
  361.    *   Termination
  362.    *
  363.    *   TscErase:     Erase the entire screen in the default
  364.    *                 background color
  365.    *   TdpDestroy:   Destroy the drawport,
  366.    *   TviCloseData: Close the data sources of the view
  367.    *   TviDestroy:   Destroy the view, freeing the allocated memory
  368.    *   TscClose:     Closes the screen object
  369.    *   TTerminate:   Perform the clean-up for DV-Tools
  370.    */
  371.   TscErase (screen);
  372.   TdpDestroy (drawport);
  373.   TviDestroy (view);
  374.   TscClose (screen);
  375.   TTerminate ();
  376.   return (EXIT_OK);
  377. }
  378.  
  379.  
  380. /*---------------
  381.  *   Palette_Pick -- User selected a color entry from the palette.
  382.  *     Determine and set the sliders based on the red, green &
  383.  *     blue values from the palette.
  384.  */
  385. /*ARGSUSED*/
  386. int 
  387. Palette_Pick (client, er, label, loc, args)
  388.      OBJECT client;
  389.      EVENT_REQUEST er;
  390.      int label;
  391.      OBJECT loc;
  392.      ADDRESS args;
  393. {
  394.   Red_Value = color_table->ct[Color_Index].red;
  395.   Green_Value = color_table->ct[Color_Index].green;
  396.   Blue_Value = color_table->ct[Color_Index].blue;
  397.   Set_colorblock ();
  398.   return (int) INPUT_USED;
  399. }
  400.  
  401.  
  402. /*---------------------
  403.  *   Handle_RGB_Sliders -- Assign red, green & blue values to the
  404.  *     color table and update the color block.
  405.  */
  406. /*ARGSUSED*/
  407. int 
  408. Handle_RGB_Sliders (client, er, label, loc, args)
  409.      OBJECT client;
  410.      EVENT_REQUEST er;
  411.      int label;
  412.      OBJECT loc;
  413.      ADDRESS args;
  414. {
  415.   color_table->ct[Color_Index].red = Red_Value;
  416.   color_table->ct[Color_Index].green = Green_Value;
  417.   color_table->ct[Color_Index].blue = Blue_Value;
  418.   Set_colorblock ();
  419.   return (int) INPUT_USED;
  420. }
  421.  
  422.  
  423. /*------------
  424.  *   Menu_Pick -- Handle picks from the main menu input object.
  425.  */
  426. /*ARGSUSED*/
  427. int 
  428. Menu_Pick (client, er, label, loc, args)
  429.      OBJECT client;
  430.      EVENT_REQUEST er;
  431.      int label;
  432.      OBJECT loc;
  433.      ADDRESS args;
  434. {
  435.  
  436.   /*
  437.    *  Examine the buffer which is updated by the input object with
  438.    *  the menu selection. Perform the appropriate action based on
  439.    *  the menu selection.
  440.    */
  441.   switch (Menu_Item)
  442.     {
  443.     case BRIGHT:
  444.       Bright ();
  445.       break;
  446.  
  447.     case DIM:
  448.       Dim ();
  449.       break;
  450.  
  451.     case PRINT:
  452.       /*
  453.        *   VOinState:  Set the input object activation state to INACTIVE
  454.        *   TdpDrawObject:  Draw an object in the drawport
  455.        *
  456.        *   Prompt the user for the file name in which to save the
  457.        *   color table.
  458.        */
  459.       VOinState (color_palette, INACTIVE);
  460.       VOinState (slider_r, INACTIVE);
  461.       VOinState (slider_g, INACTIVE);
  462.       VOinState (slider_b, INACTIVE);
  463.       VOinState (menu_bar, INACTIVE);
  464.       TdpDrawObject (drawport, text_input);
  465.       break;
  466.  
  467.     case QUIT:
  468.       Quit = YES;
  469.       break;
  470.  
  471.     default:
  472.       break;
  473.     }
  474.   return (int) INPUT_USED;
  475. }
  476.  
  477.  
  478. /*---------
  479.  *   Bright -- Increment the slider input objects representing
  480.  *     the Red, Green and Blue value by one as well as incrementing
  481.  *     the color table entry.  And lastly, update the color block.
  482.  */
  483. void Bright ()
  484. {
  485.  
  486.   if (color_table->ct[Color_Index].red < 255)
  487.     {
  488.       Red_Value++;
  489.       color_table->ct[Color_Index].red =
  490.         color_table->ct[Color_Index].red + 1;
  491.     }
  492.  
  493.   if (color_table->ct[Color_Index].green < 255)
  494.     {
  495.       Green_Value++;
  496.       color_table->ct[Color_Index].green =
  497.         color_table->ct[Color_Index].green + 1;
  498.     }
  499.  
  500.   if (color_table->ct[Color_Index].blue < 255)
  501.     {
  502.       Blue_Value++;
  503.       color_table->ct[Color_Index].blue =
  504.         color_table->ct[Color_Index].blue + 1;
  505.     }
  506.  
  507.   Set_colorblock ();
  508. }
  509.  
  510.  
  511. /*------
  512.  *   Dim -- Decrement the slider input objects representing the
  513.  *     Red, Green and Blue value by one as well as decrementing
  514.  *     the color table entry.  And lastly, update the color block.
  515.  */
  516. void Dim ()
  517. {
  518.  
  519.   if (color_table->ct[Color_Index].red > 0)
  520.     {
  521.       Red_Value--;
  522.       color_table->ct[Color_Index].red =
  523.         color_table->ct[Color_Index].red - 1;
  524.     }
  525.  
  526.   if (color_table->ct[Color_Index].green > 0)
  527.     {
  528.       Green_Value--;
  529.       color_table->ct[Color_Index].green =
  530.         color_table->ct[Color_Index].green - 1;
  531.     }
  532.  
  533.   if (color_table->ct[Color_Index].blue > 0)
  534.     {
  535.       Blue_Value--;
  536.       color_table->ct[Color_Index].blue =
  537.         color_table->ct[Color_Index].blue - 1;
  538.     }
  539.   Set_colorblock ();
  540. }
  541.  
  542.  
  543. /*-----------------
  544.  *   Set_colorblock -- Set the working color table and update
  545.  *     the filled rectangle representing the color to be used
  546.  *     for the currently selected color index.
  547.  */
  548. void Set_colorblock ()
  549. {
  550.   ATTRIBUTES Attributes;
  551.  
  552.   /*
  553.    *  GRs_color_table:    Sets up the color table
  554.    *  VOobAtGet:    Get current attributes of an object
  555.    *  VOcoCreate:    Create a color object
  556.    *  VOobAtSet:    Set new attributes of an object
  557.    *  TdpDrawObject:    Draw an object in the drawport
  558.    *
  559.    *  Set the color table for the device. retrieve the attributes
  560.    *  for the filled rectangle block and set the foreground color.
  561.    *  Finally, draw the object.
  562.    */
  563.   GRs_color_table (color_table);
  564.   VOobAtGet (color_block, &Attributes);
  565.   Attributes.foreground_color = VOcoCreate (COLOR_COMPONENTS,
  566.                                    color_table->ct[Color_Index].red,
  567.                                    color_table->ct[Color_Index].green,
  568.                                    color_table->ct[Color_Index].blue);
  569.   VOobAtSet (color_block, &Attributes);
  570.   TdpDrawObject (drawport, color_block);
  571. }
  572.  
  573.  
  574. /*----------------
  575.  *   SaveColorFile -- saves the rgb values for each entry in
  576.  *     the color table to the filename specified by the user.
  577.  */
  578. /*ARGSUSED*/
  579. int 
  580. SaveColorFile (client, er, label, loc, args)
  581.      OBJECT client;
  582.      EVENT_REQUEST er;
  583.      int label;
  584.      OBJECT loc;
  585.      ADDRESS args;
  586. {
  587.   int i;
  588.   FILE *fp;
  589.  
  590.   /*
  591.    *   TdpEraseObject:  Erase an object in a drawport
  592.    *   VOinState:    Set the activation flag for the input object
  593.    *
  594.    *   Erase the popup text entry input object and reactivate the
  595.    *   other input areas of the screen.
  596.    */
  597.   TdpEraseObject (drawport, text_input);
  598.   VOinState (color_palette, ACTIVE);
  599.   VOinState (slider_r, ACTIVE);
  600.   VOinState (slider_g, ACTIVE);
  601.   VOinState (slider_b, ACTIVE);
  602.   VOinState (menu_bar, ACTIVE);
  603.  
  604.   /*
  605.    * Check the value of filename. If the user did not enter a
  606.    * name then return.
  607.    */
  608.   if (strcmp (filename, "") == 0)
  609.     return (int) INPUT_USED;
  610.  
  611.   /*
  612.    * Open and create the file in which the color table
  613.    * information will be stored. Print the color table
  614.    * entries to the file and close the stream.
  615.    */
  616.   fp = fopen (filename, "w");
  617.   if (fp == (FILE *) 0)
  618.     {
  619.       TdpEraseObject (drawport, msg_object);
  620.       VOvtSetString (msg_object, "Error: Color table was not saved");
  621.       TdpDrawObject (drawport, msg_object);
  622.       return (int) INPUT_USED;
  623.     }
  624.  
  625.   for (i = 0; i < color_table->ctsize; i++)
  626.     fprintf (fp, " %d\t %d\t %d\n",
  627.                       color_table->ct[i].red,
  628.                       color_table->ct[i].green,
  629.                       color_table->ct[i].blue);
  630.   fclose (fp);
  631.  
  632.   /*
  633.    *  Indicate that the color table has been saved properly using
  634.    *  the message string object.
  635.    */
  636.   TdpEraseObject (drawport, msg_object);
  637.   VOvtSetString (msg_object, "Color table saved in specified file");
  638.   TdpDrawObject (drawport, msg_object);
  639.  
  640.   return (int) INPUT_USED;
  641. }
  642.  
  643.  
  644. /*------------
  645.  *   RebindVdp -- rebinds all the necessary vdps to appropriate
  646.  *    internal program variables.
  647.  */
  648. /*ARGSUSED*/
  649. ADDRESS 
  650. RebindVdps (data_obj, vdp, argblock)
  651.      OBJECT data_obj;
  652.      ADDRESS vdp;
  653.      ADDRESS argblock;
  654. {
  655.   char *name;
  656.  
  657.   /*
  658.    *   VGvdvarname:  Gets a pointer to the variable name
  659.    *
  660.    *   The name of the variable descriptor is used to
  661.    *   determine which buffer to rebind to.  If the
  662.    *   variable does not have a name then return.
  663.    */
  664.   name = VGvdvarname (vdp);
  665.   if (!name)
  666.     return V_CONTINUE_TRAVERSAL;
  667.  
  668.   if (strcmp (name, "index") == 0)
  669.     TvdPutBuffer (vdp, (ADDRESS) & Color_Index);
  670.   else if (strcmp (name, "menu_bar") == 0)
  671.     TvdPutBuffer (vdp, (ADDRESS) & Menu_Item);
  672.   else if (strcmp (name, "R") == 0)
  673.     TvdPutBuffer (vdp, (ADDRESS) & Red_Value);
  674.   else if (strcmp (name, "G") == 0)
  675.     TvdPutBuffer (vdp, (ADDRESS) & Green_Value);
  676.   else if (strcmp (name, "B") == 0)
  677.     TvdPutBuffer (vdp, (ADDRESS) & Blue_Value);
  678.   else if (strcmp (name, "Text") == 0)
  679.     TvdPutBuffer (vdp, filename);
  680.  
  681.   return V_CONTINUE_TRAVERSAL;
  682. }
  683.